# It is recommended to test the script on a local machine for its purpose and effects. # ManageEngine Desktop Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description - Script to enforce password policy to a all the users in a computer # Configuration Type - COMPUTER # !/usr/bin/bash pwpolicy -n /Local/Default -setglobalpolicy "usingHistory=5 canModifyPasswordforSelf=1 maxMinutesUntilChangePassword=129600 requiresAlpha=1 requiresNumeric=1 minChars=8 passwordCannotBeName=1 requiresMixedCase=1 requiresSymbol=1" sudo defaults write /Library/Preferences/com.apple.loginwindow PasswordExpirationDays 14 errcode=$? if [ "$errcode" -ne 0 ]; then echo "" echo "Failed to apply with errorcode $errcode" 1>&2 echo "" exit 1 fi echo "Password Policy applied successfully" 1>&2